package com.wwwc.index.web.servlet;

import java.io.*;
import java.util.*;

import javax.servlet.*;
import javax.servlet.http.*;
import java.text.DecimalFormat;

import com.wwwc.util.web.*;
import com.wwwc.index.web.ejb.database.*;

public class StockRecord implements Serializable {
    private String  bs      = null;
    private double  cost    = 0.0;
    private String  tick    = null;
    private int     share   = 0;
    private double  price   = 0.0;
    private String  date    = null;

    public StockRecord getRecord () {
	return this;
    }

    public StockRecord() 
    {
	this("", 0.0, "", 0, 0.0, "" );
    }
   
    public StockRecord(String buy_sell, double cost, String tick, int share, double price, String date )
    {
	setBuySell( buy_sell );
	setCost   ( cost );
	setTick   ( tick );
	setShare  ( share );
	setPrice  ( price );
	setDate   ( date );
    }

    public StockRecord(Vector v )
    {
	try {
	    setBuySell(v.elementAt(0));
	    setCost   (v.elementAt(1));
	    setTick   (v.elementAt(2));
	    setShare  (v.elementAt(3));
	    setPrice  (v.elementAt(4));
	    setDate   (v.elementAt(5));
	}
	catch(Exception e) {
	    System.out.println("StockRecord(v):Error:"+e);
	}
    }

    public StockRecord(ArrayList a )
    {
	setBuySell(a.get(0));
	setCost   (a.get(1));
	setTick   (a.get(2));
	setShare  (a.get(3));
	setPrice  (a.get(4));
	setDate   (a.get(5));
    }

    public void setBuySell(String bs) {
	this.bs = bs;
    }
    
    public void setTick( String tk )
    {
	this.tick = tk;
    }
    
    public void setCost( double cs )
    {
	this.cost = cs;
    }

    public void setShare (int sr) 
    {
	this.share = sr;
    }

    public void setPrice( double ps )
    {
	this.price = ps;
    }

    public void setDate( String dy )
    {
	this.date = dy;
    }

    public void setBuySell(Object bs) {
	this.bs = (String)bs;
    }
    
    public void setTick(Object tk )
    {
	this.tick = (String)tk;
    }
    
    public void setCost(Object cs )
    {
	this.cost = Double.parseDouble((String)cs);
    }

    public void setShare (Object sr) 
    {
	this.share = Integer.parseInt((String)sr);
    }

    public void setPrice(Object ps )
    {
	this.price = Double.parseDouble((String)ps);
    }

    public void setDate(Object dy )
    {
	this.date = (String)dy;
    }
    
    public void setDate(int d )
    {
	String temp  = ""+d;
	this.date = temp.substring(0,4)+"-"+temp.substring(4,6)+"-"+temp.substring(6);
    }
    
    //======================================================
    
    public String getTick() { 
	return tick; 
    }
      
    public double getCost()  { 
	return cost; 
    }
    
    public int getShare () { 
	return share; 
    }

    public String getBuySell() { 
	return bs; 
    }
    
    public double getPrice()  { 
	return price; 
    }
    
    public String getDate() { 
	return date; 
    }

    public int getDateIntValue() { 
	return Integer.parseInt(date.replaceAll("-","")); 
    }
}









